package com.example.easypoi.controller;


import com.example.easypoi.config.CommonResult;
import com.example.easypoi.model.Area;
import com.example.easypoi.service.AreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/area")
@Api(tags = "地区三级联查")
public class AreaController {

    @Resource
    private AreaService areaService;


    @ApiOperation("地区三级联动")
    @GetMapping("/queryList")
    public CommonResult<?> queryList() {
        List<Area> areas = areaService.regionList();
        if (CollectionUtils.isEmpty(areas)) {
            return CommonResult.failed("数据异常，请重新尝试！");
        }
        return CommonResult.success(areas);
    }

}
